package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.User;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface UserMapper {
    /**
     * 根据用户openid查询用户
     * @param openid
     * @return
     */
    @Select("select * from user where openid =#{openid}")
    User getByOpenId(String openid);

    /**
     * 插入新用户
     * @param new_user
     */
    @AutoFill(OperationType.INSERT)
    void insert(User new_user);

    /**
     * 根据用户id查询用户
     * @param userId
     * @return
     */
    @Select("select * from user where id =#{userId}")
    User getById(Long userId);

    /**
     * 根据时间段查询用户数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
